<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta charset="utf-8" />
    <link rel="stylesheet" href="../../css/newstyle.css">

    <script type="text/javascript" src="../../js/jquery/jquery-1.7.2.js"></script>
    <script type="text/javascript" src="../../js/script.js"></script>
    <style type="text/css">
         body{
            background: url('.././images/background.jpg') repeat fixed;
         }
    </style>
</head>

<body>
    <div id="backTransparent"></div>

    <!-- ДОБАВЛЕНИЕ ЗАМЕТКИ-->
    <div id="postNote">
        <span class="title">Добавление заметки</span>
        <form action="http://myblog.local/note/add/" enctype="application/x-www-form-urlencoded" method="post">
            <textarea id="addNote" rows="8" cols="50" name="noteText">Введите текст заметки...</textarea>
            <label>Ролик youtube: </label><input type="text" name="youtube">
            <input type="submit" name="addNote" value="Добавить" >
        </form>
        <button onclick="closeForm('#postNote');">Закрыть</button>
    </div>
    <!-- ДОБАВЛЕНИЕ ЗАМЕТКИ -->

    <!-- ДОБАВЛЕНИЕ КОММЕНТАРИЯ -->
    <div id="postComment">
        <span class="title">Добавление комментария</span>
        <form action="" enctype="application/x-www-form-urlencoded" method="post">
            <textarea id="addComment" rows="8" cols="50" name="commentText">Введите текст комментария...</textarea>
            <input type="submit" name="addComment" value="Добавить" >
        </form>
        <button onclick="closeForm('#postComment');">Закрыть</button>
    </div>
    <!-- ДОБАВЛЕНИЕ КОММЕНТАРИЯ  -->

    <!-- РЕДАКТИРОВАНИЕ ЗАМЕТКИ -->
    <div id="editNoteForm">
        <span class="title">Редактирование заметки</span>
        <form action="" enctype="application/x-www-form-urlencoded" method="post">
            <textarea id="editNote" rows="8" cols="50" name="noteText"></textarea>
            <input type="submit" name="editNote" value="Редактировать" >
        </form>
        <button onclick="closeForm('#editNoteForm');">Закрыть</button>
    </div>
    <!-- РЕДАКТИРОВАНИЕ ЗАМЕТКИ -->

    <div id="content">
<?php
if (!isset($this->noUserPage))
{
?>
        <div id="userinfo">
            <div class="photo">
                <img src="<?= ($this->users[$this->ownerId]['photo'] != null) ? $this->users[$this->ownerId]['photo'] : '../../images/camera.gif' ?>" alt="Аватар">
            </div>
            
            <span class="name">
                <?= '#' . $this->users[$this->ownerId]['login'] ?>
                <?php
                    if($this->users[$this->ownerId]['name'] != null)
                    {
                        echo '(';
                        echo $this->users[$this->ownerId]['name'];
                        if($this->users[$this->ownerId]['surname'] != null)
                        {
                            echo ' ' . $this->users[$this->ownerId]['surname'];
                        }
                        echo ')';
                    }
                ?>
            </span>

            <?php
            if ( isset($this->pageOwner) )
            {
            ?>
            <a class="controls" href="http://myblog.local/logout/">Выход</a>
            <a class="controls" href="http://myblog.local/settings/">Настройки</a>
            <?php
            }
            ?>

            <span class="motto"><?= ($this->users[$this->ownerId]['motto'] != null) ? $this->users[$this->ownerId]['photo'] : '' ?></span>
             <span class="karma"><?= ($this->users[$this->ownerId]['karma'] != null) ? 'Карма: ' . $this->users[$this->ownerId]['karma'] : '' ?></span>

        </div>

        <div id="notes">
            <span class="title">Заметки</span>
            <?php
            if (isset($this->pageOwner))
            {
            ?>
            <button class="addButton" onclick="showForm('#postNote');">Добавить</button>
            <?php
            }

            if (isset($this->noNotes))
            {
            ?>
            <span class="noNotes">Пользователь еще не оставлял заметок</span>
            <?php
            } else{

                foreach($this->notes as $note)
                {
            ?>
            <div id="note">
               <div class="left">
                    <div class="photo">
                        <img src="<?= ($this->users[$note['userId']]['photo'] != null) ? $this->users[$note['userId']]['photo'] : '../../images/camera.gif' ?>" alt="Аватар">
                    </div>
                   <?php
                   if (isset($this->pageOwner))
                    {
                   ?>
                   <a href="#edit" onclick="readyNoteEditForm('#editNoteForm', <?= $note['id'] ?>, '<?= $note['text'] ?>');">Редактировать</a>
                   <a href="http://myblog.local/note/remove/<?= $note['id'] ?>">Удалить</a>
                   <?php
                    }
                   ?>
                   <a href="#answer" onclick="readyCommentForm('#postComment',<?= $note['id'] ?>)">Ответить</a>
               </div>
               <div class="middle">
                    <span class="name"><?= '#' . $this->users[$note['userId']]['login'] ?></span><span class="time"><?= $note['time'] . ' ' . $note['date'] ?></span>
                    <div id="noteText" name="noteText">
                        <?= $note['text'] ?>
                    </div>
               </div>
               <div class="right">
                   <?php
                   if ($note['youtube'] != null)
                   {
                   ?>
                   <!--
                   <object style="height: 180px; width: 240px"><param name="movie" value="<?= $note['youtube'] ?>">
                       <param name="allowFullScreen" value="true">
                       <param name="allowScriptAccess" value="always">
                       <embed src="<?= $note['youtube'] ?>" type="application/x-shockwave-flash" allowfullscreen="true" allowScriptAccess="always" width="240" height="180">
                   </object>
                    -->
                       <iframe class="video" width="240" height="180" src="<?= $note['youtube'] ?>"
                       frameborder="0" allowfullscreen></iframe>
                   <?php
                   }
                   ?>
                </div>
            </div>
            <?php
            if ( isset($this->comments[$note['id']]) )
            {
                foreach($this->comments[$note['id']] as $comment)
                {
            ?>
            <div id="note" class="comment">
               <div class="left">
                    <div class="photo">
                        <img src="../../images/camera.gif" alt="Аватар">
                    </div>
                   <?php
                   if (isset($this->pageOwner))
                   {
                   ?>
                   <a href="http://myblog.local/comment/remove/<?= $comment['id'] ?>">Удалить</a>
                   <!--
                       <a href="#edit" onclick="readyNoteEditForm('#editNoteForm',50,'Text')">Редактировать</a>
                       <a href="#answer" onclick="readyCommentForm('#postComment',50)">Ответить</a>
                   -->
                   <?php
                   }
                   ?>
               </div>
               <div class="middle">
                    <span class="name"><?= $this->users[$comment['userId']]['login'] ?></span><span class="time"><?= $comment['time'] . ' ' .$comment['date'] ?></span>
                    <div id="noteText" name="noteText">
                        <?= $comment['text'] ?>
                    </div>
               </div>
            </div>
            <?php
                }
            }
                }
            }
            ?>
            
        </div>
<?php
} else{
        echo '<span style="color:red; font-size: 30px;">Пользователь не существует</span>';
    }
?>
    </div>
    
</body>

</html>